package com.sfdcj.se.meta.field;

import java.util.HashMap;

import com.sforce.soap._2006._04.metadata.CustomField;

public class NumberType extends FieldType {

	static final String TYPE = "Number";

	public int precision;

	public int scale;

	public NumberType() {
		super();
	}

	public void appendXML() {
		buf.append("<precision>" + precision + "</precision>");
		buf.append("<scale>" + scale + "</scale>");
		buf.append("<type>" + TYPE + "</type>");
	}

	@Override
	public String getTypeName() {
		return TYPE;
	}

	@Override
	public Object clone() {
		return new NumberType();
	}

	@Override
	public void setAttributes(HashMap<String, String> attributes) {
		scale = Integer.valueOf(attributes.get("scale")).intValue();
		precision = Integer.valueOf(attributes.get("precision")).intValue();
	}

	@Override
	public CustomField toCustomField() {
		CustomField field = new CustomField();
		field.setFullName(objectFullname + "." + fullname);
		field.setLabel(label);
		field.setScale(new Integer(scale));
		field.setPrecision(new Integer(precision));
		field.setType(com.sforce.soap._2006._04.metadata.FieldType.Number);
		return field;
	}		
}
